<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>实例</title>
</head>

<script>

</script>
<body>
<ul>
    <li>春</li>
    <li>夏</li>
    <li>秋</li>
    <li>冬</li>
</ul>
</body>
</html>

<script type="text/javascript">
    var arr = [];
    for(var i= 0,list = document.getElementsByTagName("li"),len = list.length;i<len;i++){
//        alert(i)
        var obj = list[i];

        list[i].myId = i;

        list[i].onclick = function(){
            alert(this.myId)
        }




    }






</script>